<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./MasterPageHome.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns="http://www.w3.org/1999/xhtml">
    <f:metadata>
        <f:viewParam name="id" value="#{editmessage.idhouse}"/>
        <f:viewParam name="idphoto" value="#{editmessage.idphoto}"/>
    </f:metadata>

    <ui:define name="Title">
        <title>Edit</title>
    </ui:define>

    <ui:define name="content">
        <h:form enctype="multipart/form-data">
            <table width="100%" border="0">
                <tr>
                    <td width="170px">
                        Title:
                    </td>
                    <td>
                        <p:inputText id="txttittle" value="#{editmessage.house.tittlehouse}" required="true" requiredMessage="Tittle is required">
                            <p:ajax update="MessageForTittle" event="keyup"/>
                            <p:ajax update="MessageForTittle" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="MessageForTittle" for="txttittle"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Type:
                    </td>
                    <td>
                        <h:selectOneMenu value="#{editmessage.house.homestyle}" style="width: 220px">
                            <f:selectItem itemLabel="Seller" itemValue="Seller"/>
                            <f:selectItem itemLabel="Lease" itemValue="Lease"/>
                        </h:selectOneMenu>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td>
                        Date Up:
                    </td>
                    <td>
                        <p:calendar
                            id="txtdateup"
                            pattern="MM/dd/yyyy"
                            yearRange="c-50:c+50"
                            navigator="true"
                            size="22"
                            required="true"
                            value="#{editmessage.house.dateUp}"
                            style="width: 250px">
                            <p:ajax update="messageForCalendar" event="keyup"/>
                            <p:ajax update="messageForCalendar" event="blur"/>
                        </p:calendar>
                    </td>
                    <td>
                        <p:message id="messageForCalendar" for="txtdateup"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Square footage Earth:
                    </td>
                    <td>
                        <p:inputText id="txtearth" value="#{editmessage.house.squarefootageEarth}" required="true" requiredMessage="Square footage Earth is required">
                            <p:ajax update="messageForEarth" event="keyup"/>
                            <p:ajax update="messageForEarth" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageForEarth" for="txtearth"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Square footage House:
                    </td>
                    <td>
                        <p:inputText id="txthouse" value="#{editmessage.house.squarefootageHouse}" required="true" requiredMessage="Square footage House is required">
                            <p:ajax update="messageForHouse" event="keyup"/>
                            <p:ajax update="messageForHouse" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageForHouse" for="txthouse"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        City:
                    </td>
                    <td>
                        <p:inputText id="txtcity" value="#{editmessage.house.city}" required="true" requiredMessage="City is required">
                            <p:ajax update="messageForCity" event="keyup"/>
                            <p:ajax update="messageForCity" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageForCity" for="txtcity"/>
                    </td>    
                </tr>
                <tr>
                    <td>
                        Details Location:
                    </td>
                    <td>
                        <p:inputText id="txtlocation" value="#{editmessage.house.location}" required="true" requiredMessage="Location is required">
                            <p:ajax update="messageForLocation" event="keyup"/>
                            <p:ajax update="messageForLocation" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageForLocation" for="txtlocation"/>
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td colspan="2">
                        Bedroom:
                        <h:selectOneMenu id="txtbedroom" value="#{editmessage.house.bedroom}">
                            <f:selectItem itemLabel="1" itemValue="1"/>
                            <f:selectItem itemLabel="2" itemValue="2"/>
                            <f:selectItem itemLabel="3" itemValue="3"/>
                            <f:selectItem itemLabel="4" itemValue="4"/>
                            <f:selectItem itemLabel="5" itemValue="5"/>
                            <f:selectItem itemLabel="6" itemValue="6"/>
                            <f:selectItem itemLabel="7" itemValue="7"/>
                            <f:selectItem itemLabel="8" itemValue="8"/>
                            <f:selectItem itemLabel="9" itemValue="9"/>
                            <f:selectItem itemLabel="10" itemValue="10"/>
                            <f:selectItem itemLabel="11" itemValue="11"/>
                            <f:selectItem itemLabel="12" itemValue="12"/>
                            <f:selectItem itemLabel="13" itemValue="13"/>
                            <f:selectItem itemLabel="14" itemValue="14"/>
                            <f:selectItem itemLabel="15" itemValue="15"/>
                            <f:selectItem itemLabel="16" itemValue="16"/>
                            <f:selectItem itemLabel="17" itemValue="17"/>
                            <f:selectItem itemLabel="18" itemValue="18"/>
                            <f:selectItem itemLabel="19" itemValue="19"/>
                            <f:selectItem itemLabel="20" itemValue="20"/>
                        </h:selectOneMenu>
                        &nbsp;&nbsp;
                        Bathroom:
                        <h:selectOneMenu id="txtbathroom" value="#{editmessage.house.bathroom}">
                            <f:selectItem itemLabel="1" itemValue="1"/>
                            <f:selectItem itemLabel="2" itemValue="2"/>
                            <f:selectItem itemLabel="3" itemValue="3"/>
                            <f:selectItem itemLabel="4" itemValue="4"/>
                            <f:selectItem itemLabel="5" itemValue="5"/>
                            <f:selectItem itemLabel="6" itemValue="6"/>
                            <f:selectItem itemLabel="7" itemValue="7"/>
                            <f:selectItem itemLabel="8" itemValue="8"/>
                            <f:selectItem itemLabel="9" itemValue="9"/>
                            <f:selectItem itemLabel="10" itemValue="10"/>
                            <f:selectItem itemLabel="11" itemValue="11"/>
                            <f:selectItem itemLabel="12" itemValue="12"/>
                            <f:selectItem itemLabel="13" itemValue="13"/>
                            <f:selectItem itemLabel="14" itemValue="14"/>
                            <f:selectItem itemLabel="15" itemValue="15"/>
                            <f:selectItem itemLabel="16" itemValue="16"/>
                            <f:selectItem itemLabel="17" itemValue="17"/>
                            <f:selectItem itemLabel="18" itemValue="18"/>
                            <f:selectItem itemLabel="19" itemValue="19"/>
                            <f:selectItem itemLabel="20" itemValue="20"/>
                        </h:selectOneMenu>
                        &nbsp;&nbsp;          
                        Livingroom:
                        <h:selectOneMenu id="livingroom" value="#{editmessage.house.livingroom}">
                            <f:selectItem itemLabel="0" itemValue="0"/>
                            <f:selectItem itemLabel="1" itemValue="1"/>
                            <f:selectItem itemLabel="2" itemValue="2"/>
                            <f:selectItem itemLabel="3" itemValue="3"/>
                            <f:selectItem itemLabel="4" itemValue="4"/>
                            <f:selectItem itemLabel="5" itemValue="5"/>
                            <f:selectItem itemLabel="6" itemValue="6"/>
                            <f:selectItem itemLabel="7" itemValue="7"/>
                            <f:selectItem itemLabel="8" itemValue="8"/>
                            <f:selectItem itemLabel="9" itemValue="9"/>
                            <f:selectItem itemLabel="10" itemValue="10"/>
                        </h:selectOneMenu>
                    </td>   
                </tr>
                <tr>
                    <td>
                        Type of House:
                    </td>
                    <td>
                        <h:selectOneMenu id="txttypehouse" value="#{editmessage.house.typehouse}" style="width: 220px">
                            <f:selectItem itemLabel="Home" itemValue="Home"/>
                            <f:selectItem itemLabel="Villa" itemValue="Villa"/>
                            <f:selectItem itemLabel="Apartment" itemValue="Apartment"/>
                            <f:selectItem itemLabel="Commercial Area" itemValue="Commercial Area"/>
                        </h:selectOneMenu>
                    </td>
                    <td>

                    </td>
                </tr>
                <tr>
                    <td>
                        Price:
                    </td>
                    <td>
                        <p:inputText id="txtprice" value="#{editmessage.house.deposit}" required="true" requiredMessage="Price is required">
                            <p:ajax update="messageForPrice" event="keyup"/>
                            <p:ajax update="messageForPrice" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageForPrice" for="txtprice"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Introduction:
                    </td>
                    <td>
                        <p:inputText id="txtintroduction" value="#{editmessage.house.introduction}" required="true" requiredMessage="Introduction is required">
                            <p:ajax update="messageforIntroduction" event="keyup"/>
                            <p:ajax update="messageforIntroduction" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageforIntroduction" for="txtintroduction"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Type Payment: 
                    </td>
                    <td>
                        <p:inputText id="txtpayment" value="#{editmessage.house.typepayment}" required="true" requiredMessage="Payment is required">
                            <p:ajax update="messageforPayment" event="keyup"/>
                            <p:ajax update="messageforPayment" event="blur"/>
                        </p:inputText>
                    </td>
                    <td>
                        <p:message id="messageforPayment" for="txtpayment"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Link Map:
                    </td>
                    <td align="center">
                        <h:inputTextarea id="txtlinkmap" value="#{editmessage.house.linkmap}" required="true" requiredMessage="Link Map is required" style="width: 350px">
                            <p:ajax update="MessageForLinkMap" event="keyup"/>
                            <p:ajax update="MessageForLinkMap" event="blur"/>
                        </h:inputTextarea>
                    </td>
                    <td>
                        <p:message id="MessageForLinkMap" for="txtlinkmap"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <p:panel id="albumPanel" style="margin: 15px 0px 7px 0px">
                            <p:fileUpload 
                                fileUploadListener="#{editmessage.handleFileUpload}"
                                update="photos"
                                multiple="true"                    
                                allowTypes="/(\.|\/)(gif|jpe?g|png|bmp)$/"
                                style="margin: 10px">
                            </p:fileUpload>
                            <h:panelGroup id="photos">
                                <ui:repeat value="#{editmessage.photos}" var="photo">
                                    <div class="one-pic">
                                        <p:graphicImage 
                                            value="#{photo.linkImageHouse}"/>
                                    </div>
                                </ui:repeat>
                                <div class="clear"></div>
                            </h:panelGroup>
                        </p:panel>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <div class="photobody">
                            <ui:repeat value="#{editmessage.listphoto}" var="photo">
                                <div class="photoBorder" onmouseover="toolVisible('#{photo.id}')" 
                                        onmouseout="toolInvisible('#{photo.id}')">
                                    <p:graphicImage value="#{photo.linkImageHouse}"                                        
                                                    width="153px" 
                                                    height="153px"
                                                    >
                                    </p:graphicImage>
                                    <span
                                        id="#{photo.id}" 
                                        style="position: absolute; top: 0px; right: 0px; visibility: hidden">
                                        <h:commandLink
                                            ajax="false"
                                            class="deleteIcon1"
                                            action="#{editmessage.Deletelinkimage}"
                                            onclick="return confirm('Are you sure to delete this photo?')">
                                            <f:param name="idphoto" value="#{photo.id}"/>
                                        </h:commandLink>
                                    </span>
                                </div>
                            </ui:repeat>
                            <div class="clear"></div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <p:commandButton value="Done" action="#{editmessage.Updatemessage}" style="width: 120px"/>
                    </td>
                </tr>
            </table>
        </h:form>
    </ui:define>

</ui:composition>
